package cn.com.jenson.web.carport.controller;

import cn.com.jenson.common.BasicController;
import cn.com.jenson.common.ImportVerifierVo;
import cn.com.jenson.common.Result;
import cn.com.jenson.common.SelectVo;
import cn.com.jenson.dao.carport.bo.CarportBo;
import cn.com.jenson.dao.carport.searchBo.CarportSearchBo;
import cn.com.jenson.dao.carport.vo.CarportVo;
import cn.com.jenson.entity.carport.Carport;
import cn.com.jenson.service.carport.service.CarportService;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/carport")
public class CarportController implements BasicController<CarportVo, CarportBo, CarportSearchBo> {

    @Resource
    private CarportService carportService;


    @Override
    public Result<Page<CarportVo>> pageAll(@RequestBody CarportSearchBo carportSearchBo) {
        return Result.suc(carportService.pageAll(carportSearchBo));
    }

    @Override
    public Result<List<CarportVo>> listAll(@RequestBody CarportSearchBo carportSearchBo) {
        return Result.suc(carportService.listAll(carportSearchBo));
    }

    @Override
    public Result<CarportVo> get(@RequestBody CarportSearchBo carportSearchBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carportService.get(carportSearchBo));
    }

    @Override
    public Result<CarportVo> edit(@RequestBody CarportBo carportBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carportService.edit(carportBo));
    }

    @Override
    public Result<List<CarportVo>> editAll(@RequestBody List<CarportBo> carportBos) {
        return Result.suc(carportService.editAll(carportBos));
    }

    @Override
    public Result<CarportVo> deleted(@RequestBody CarportSearchBo carportSearchBo) throws InstantiationException, IllegalAccessException {
        return Result.suc(carportService.deleted(carportSearchBo));
    }

    @Override
    public Result<List<CarportVo>> deletedAll(@RequestBody List<CarportSearchBo> carportSearchBos) throws InstantiationException, IllegalAccessException {
        return Result.suc(carportService.deletedAll(carportSearchBos));
    }

    @Override
    public List<ImportVerifierVo> importTemplateVerifiers() {
        return carportService.importTemplateVerifiers();
    }

    @Override
    public void importTemplateDownload(@RequestBody HttpServletResponse response) throws IOException {
        carportService.importTemplateDownload(response);
    }

    @Override
    public Result<List<SelectVo<String, Integer, CarportVo>>> option() {
        return Result.suc(carportService.option());
    }

    public Result<CarportVo> simulate(@RequestBody CarportBo carportBo){
        return Result.suc(carportService.simulate(carportBo));
    }
}
